package thread.synchronize.s1;

/**
 * @author cuihao
 * @date 2017/12/8
 */
public class Run {
    public static void main(String[] args) {
        HasSelfPrivateNum num = new HasSelfPrivateNum();
        //HasSelfPrivateNum num1 = new HasSelfPrivateNum();
        ThreadA threadA = new ThreadA(num);
        threadA.start();
        ThreadB threadB = new ThreadB(num);
        threadB.start();
    }
}


//由于HasSelfPrivateNum添加了同步关键字，所以threadA休眠时会锁死addI方法，
// 这样threadB要等到资源（addI方法）可用时在执行方法
/*
 * 两个线程访问同一个对象内的同步方法时安全的
 *
 *
 * */